unit Ludialog;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, KCondition, Grids, Wwdbigrd, Wwdbgrid, StdCtrls, KEdit, ExtCtrls,
  DB, ADODB;

type
  TDialog = class(TForm)
    Panel1: TPanel;
    KEdit1: TKEdit;
    qLookup: TADOQuery;
    dsLookup: TDataSource;
    Panel4: TPanel;
    Panel2: TPanel;
    KCondition1: TKCondition;
    Panel3: TPanel;
    wwDBGrid1: TwwDBGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure wwDBGrid1DblClick(Sender: TObject);
    procedure KEdit1Change(Sender: TObject);
    procedure KEdit1SpeedButtonClick(Sender: TObject; var Accept: Boolean);
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Dialog: TDialog;

implementation
uses uDataModule, uMain;
{$R *.dfm}


procedure TDialog.FormCreate(Sender: TObject);
begin
      KEdit1.Left   := Panel1.Left+1;
      KEdit1.Top    := Panel1.Top+1;
      KEdit1.Height := 21;
      KEdit1.Width  := (((Panel1.Width-KEdit1.INITSpeedButton.Width)+KEdit1.INITSpeedButton.Spacing)) -5; //-DBNavigator1.Width-1;
      KEdit1.INITSpeedButton.AllowAllup := True;
      KEdit1.INITSpeedButton.Groupindex := 1;
      KEdit1.INITSpeedButton.Down := Panel2.Visible;

      with wwDBGrid1 do
      begin
        Options := [dgTitles, dgIndicator, dgColLines, dgColumnResize, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit];
        TitleColor := $00F1CCAB;
        FooterColor := $00F1CCAB;
        FooterCellColor := $00F1CCAB;
        TitleFont.Color := clRed;
      end;

   //   DBNavigator1.Left := (KEdit1.Width+KEdit1.INITSpeedButton.Width+KEdit1.INITSpeedButton.Spacing)-1;
   //   DBNavigator1.Top  := Panel1.Top+1;


end;

procedure TDialog.FormClose(Sender: TObject; var Action: TCloseAction);
begin
        Dialog := nil;
        Action := caFree;
end;

procedure TDialog.wwDBGrid1DblClick(Sender: TObject);
begin
        ModalResult := mrOk;
end;

procedure TDialog.KEdit1Change(Sender: TObject);
begin
      if KEdit1.Text<>'' then begin
      Screen.Cursor := crHourGlass;
      try
        try
          qLookup.Locate(wwDBGrid1.Columns[0].FieldName, KEdit1.Text,
            [loCaseInsensitive, loPartialKey]);
        except
         (* do nothing *)
        end;
      finally
        Screen.Cursor := crDefault;
      end;
    end;
end;

procedure TDialog.KEdit1SpeedButtonClick(Sender: TObject;
  var Accept: Boolean);
begin
        Panel2.Visible := not Panel2.Visible;
        if Panel4.Visible then
        begin
        Panel4.Visible := False;
        Panel4.Visible := True;
        end;
        KEdit1.INITSpeedButton.Down := Panel2.Visible;
end;

procedure TDialog.FormResize(Sender: TObject);
begin
      KEdit1.Left   := Panel1.Left+1;
      KEdit1.Top    := Panel1.Top+1;
      KEdit1.Height := 21;
      KEdit1.Width  := (((Panel1.Width-KEdit1.INITSpeedButton.Width)+KEdit1.INITSpeedButton.Spacing)) -5; //-DBNavigator1.Width-1;

end;

end.
